package sgt.onlinetest.controller;

import java.io.IOException;

import java.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class InstallSample
 */
public class InstallSample extends HttpServlet {

    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public InstallSample() {
        super();
        // TODO Auto-generated constructor stub
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try {
            SampleInstaller.installSample();
        } catch (ParseException ex) {
            Logger.getLogger(InstallSample.class.getName()).log(Level.SEVERE, null, ex);
            throw new ServletException(ex);
        }
        request.setAttribute("msg", "Sample data was installed successfully");
        request.getRequestDispatcher("/WEB-INF/installSample.jsp").forward(request, response);

    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
    }
}
